package com.swt.controller.S_controller;

import com.alibaba.fastjson.JSON;
import com.swt.domain.Club;
import com.swt.service.S_service.GetClubService;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.List;

@Controller
public class GetClubController {
    /*
    * 获取所有店铺的controller
    * */
    //注入services
    @Resource(name = "s_getclubservice")
    private GetClubService getClubService;

    @RequestMapping("/S_getClub")
    @ResponseBody
    public String getClub(){
        /*调用services*/
        List<Club> list = getClubService.getClub();
        System.out.println("级联查询====================================");
        System.out.println(list);
        /*转换为json*/
        String club=JSON.toJSONString(list);
        System.out.println(club);
        return club;
    }
    /*根据总店id查询总店信息级联查询所有的分店信息*/
    @RequestMapping("/S_getClubByClubid")
    @ResponseBody
    public String getClub(int clubId){
        /*调用services*/
        Club club1 = getClubService.getclubByid(clubId);
        /*转换为json*/
        String club=JSON.toJSONString(club1);
        return club;
    }
}
